import { ApiRes, BannerItem, BrandItem, GoodItem, HomeProduct, HotItem, specialItem } from "@/types";
import http from "@/utils/request";
import { defineStore } from "pinia";
export default defineStore('home',{
    state() {
        return {
       bannerList:[] as BannerItem[],
       goodsList:[]as GoodItem[],
       hotList:[] as HotItem[],
       Brandlist: [] as BrandItem[],
       productList:[] as HomeProduct[],
       specialList:[] as specialItem[]
        }
    },
    actions:{
    async getBannerList(){
    const res=await http.get<ApiRes<BannerItem[]>>('/home/banner')  
    this.bannerList=res.data.result
   },
   async getGoodlist(){
    const res=await http.get<ApiRes<GoodItem[]>>('/home/new')  
    this.goodsList=res.data.result
   },
   async getHotlist(){
    const res=await http.get<ApiRes<HotItem[]>>('/home/hot')  
    this.hotList=res.data.result
   },
   async getBrandlist(){
    const res=await http.get<ApiRes<BrandItem[]>>('/home/brand')  
    this.Brandlist=res.data.result
   },
   async getProductlist(){
    const res=await http.get<ApiRes<HomeProduct[]>>('/home/goods')  
    this.productList=res.data.result
   },
   async getSpeciallist(){
    const res=await http.get<ApiRes<specialItem[]>>('/home/special')  
   this.specialList=res.data.result
   
   
   }
    },
    getters:{

    }
})